package com.infinit.selfhelp.common.config

import com.infinit.selfhelp.common.net.interceptor.LoggingInterceptor
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
interface ConfigModule {

    companion object {
        @Singleton
        @Provides
        fun provideMoshi(): Moshi = MoshiProvider.builder
            // add business adapter
            .addLast(KotlinJsonAdapterFactory())
            .build()

        @Singleton
        @Provides
        fun provideLoggingInterceptor() = LoggingInterceptor()
    }
}
